const pg = require('pg');

const pool = new pg.Pool();

pool.on('error', err => console.error('Postgres Error:', err));

exports.pool = pool;

exports.fix = function (data) {
	if (data.tags != null && data.names.length === data.tags.length) {
		return data; // correct data
	}

	const newTags = [];
	data.names.forEach(() => {
		newTags.push('');
	})

	data.tags = newTags;

	return data;
};
